﻿Public Class DmNghiepVu
    Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean
        If keyData = (Keys.Control Or Keys.N) Then
            Return Me.DmnghiepvuIUltraGrid.getTaoMoi()
        End If
        If keyData = (Keys.Control Or Keys.S) Then
            Me.DmnghiepvuIUltraGrid.getLuu()
            Return True
        End If
        If keyData = (Keys.Control Or Keys.D) Then
            Return Me.DmnghiepvuIUltraGrid.getXoa()
        End If
        If keyData = (Keys.Control Or Keys.P) Then
            Return Me.getIn()
        End If
        If keyData = (Keys.Control Or Keys.R) Then
            Return Me.DmnghiepvuIUltraGrid.getRefresh()
        End If
        If keyData = (Keys.Control Or Keys.Q) Then
            Return getThoat()
        End If
        Return MyBase.ProcessCmdKey(msg, keyData)
    End Function
    Private Sub DmNghiepVu_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       
        Me.Cursor = Cursors.WaitCursor 'thêm Cursors(con trỏ) để tạo đồng hồ cát
        Me.DmtinhtrangTableAdapter.Fill(Me.ErpharmaDataSet.dmtinhtrang)
        Me.DmnghiepvuTableAdapter.Fill(Me.ErpharmaDataSet.dmnghiepvu)
        Me.DmnghiepvuIUltraGrid.setDoiTuongXuLyDuLieu(Me.ErpharmaDataSet.dmnghiepvu, Me.DmnghiepvuBindingSource, Me.DmnghiepvuTableAdapter, Me.ErpharmaDataSet)
        Me.DmnghiepvuIUltraGrid.setGiaoDienVua()
        Me.DmnghiepvuIUltraGrid.setTimKiemTrenCotUltraGrid()
        Me.DmnghiepvuIUltraGrid.setChoPhepLuuXongKhongThemDong() 'sau khi lưu thì không hiện lên dòng trống ở cuối lưới
        Me.DmnghiepvuIUltraGrid.setChoPhepMenuStrip_In() ' chỉ cho phép menustrip có chức năng in 
        Me.DmnghiepvuIUltraGrid.setThemIUltraDropDown(Me.DmtinhtrangIUltraDropDown, Me.ErpharmaDataSet.dmtinhtrang)
        Me.DmtinhtrangIUltraDropDown.setGiaoDien_An_ColumnHeader()
        Me.Cursor = Cursors.Default ' trở về mặc định con trỏ
    End Sub
    Private Sub btnTaoMoi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTaoMoi.Click
        Me.DmnghiepvuIUltraGrid.getTaoMoi()
    End Sub
    Private Sub btnLuu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLuu.Click
        Me.DmnghiepvuIUltraGrid.getLuu()
    End Sub
    Private Sub btnXoa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnXoa.Click
        Me.DmnghiepvuIUltraGrid.getXoa()
    End Sub
    Private Sub btnLamTuoi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLamTuoi.Click
        Me.DmnghiepvuIUltraGrid.getRefresh()
    End Sub
   
    Private Function getIn() As Boolean
        Try
            Dim rp As DmNghiepVu_Report = New DmNghiepVu_Report
            rp.setDt(Me.DmnghiepvuIUltraGrid.getDatatableTuIUltraGrid("dmnghiepvu"))
            rp.Show()
            Me.DmnghiepvuIUltraGrid.DataSource = Me.ErpharmaDataSet.dmnghiepvu
        Catch ex As Exception
            ' Return False
            MsgBox("Xảy ra lỗi :" & ex.Message, MsgBoxStyle.Information, "Thông báo")
        End Try
        Return True
    End Function
    Private Sub btnIn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnIn.Click
        getIn()
    End Sub
    Private Function getThoat() As Boolean
        Try
            Me.Dispose()
            Me.Close()
        Catch ex As Exception
            Return False
        End Try
        Return True
    End Function
    Private Sub btnThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThoat.Click
        getThoat()
    End Sub
End Class